$(function(){
	//查询系统通知
	$.post(contextPath + '/auth/currentUser/queryNotification.dhc').done(function(data) {
		var result=data.data;
		if(result.notificationCnt>0){
			//添加晃动样式
			$('#btnNotification i').addClass('bell-animation-horizonal');
			$('#btnNotification').append('<span class="notificationBadge">'+result.notificationCnt+'</span>');
			for(var o in result.notificationType){
				$('#notificationUl').append(getType(result.notificationType[o]));
			}
		}
		else{
			//移出晃动样式
			$('#btnNotification i').removeClass('bell-animation-horizonal');
		}
	});
	function getType(type){
		switch (type){
		case 'hospNotification':
			return '<li data-target="'+type+'"><a href="#" onclick=hospNotification();><i class="fa fa-envelope fa-fw"></i>科室未维护科院区</a></li>';
			break;
		case 'depNotification':
			return '<li data-target="'+type+'"><a href="#" onclick=depNotification();><i class="fa fa-envelope fa-fw"></i>科室未维护科室组</a></li>';
			break;
		case 'wardNotification':
			return '<li data-target="'+type+'"><a href="#" onclick=wardNotification();><i class="fa fa-qq fa-fw"></i>病区未维护科室</a></li>';
			break;
		
		}
	}
});
function hospNotification(){
	$.post(contextPath + '/Department/getHospNotification.dhc').done(function(data) {
		var result=data.data;
		$.post(contextPath + '/pages/common/top-dialog-buttons.jsp').done(function(data){
  			var dialog  = $(data);
  			dialog.find(".modal-title").html("提示信息");
  			dialog.find(".modal-dialog").css({width:"500px"});
  			dialog.find(".modal-body").html('');
  			dialog.find(".modal-body").css({"min-height":"80px"});
  			dialog.modal({
  				keyboard: false
  			}).on({
  				'hidden.bs.modal' : function(){
  					$(this).remove();
  				},
  				'shown.bs.modal' : function(){
  					var tmpStr = "<div><strong style='line-height:30px;'>以下科室未设置其隶属的院区，请联系管理员设置</strong></div>";
  					tmpStr += "<div id='newAddDeps'></div>";
  					dialog.find(".modal-body").append(tmpStr);
  		        	dialog.find(".modal-body #newAddDeps").html(result.join(','));
  				}
  			});
 			});
	});
}
function depNotification(){
	$.post(contextPath + '/Department/getDepNotification.dhc').done(function(data) {
		var result=data.data;
		$.post(contextPath + '/pages/common/top-dialog-buttons.jsp').done(function(data){
  			var dialog  = $(data);
  			dialog.find(".modal-title").html("提示信息");
  			dialog.find(".modal-dialog").css({width:"500px"});
  			dialog.find(".modal-body").html('');
  			dialog.find(".modal-body").css({"min-height":"80px"});
  			dialog.modal({
  				keyboard: false
  			}).on({
  				'hidden.bs.modal' : function(){
  					$(this).remove();
  				},
  				'shown.bs.modal' : function(){
  					var tmpStr = "<div><strong style='line-height:30px;'>以下科室未设置其隶属的科室组，请联系管理员设置</strong></div>";
  					tmpStr += "<div id='newAddDeps'></div>";
  					dialog.find(".modal-body").append(tmpStr);
  		        	dialog.find(".modal-body #newAddDeps").html(result.join(','));
  				}
  			});
 			});
	});
}
function wardNotification(){
	$.post(contextPath + '/Ward/getWardNotification.dhc').done(function(data) {
		var result=data.data;
		$.post(contextPath + '/pages/common/top-dialog-buttons.jsp').done(function(data){
  			var dialog  = $(data);
  			dialog.find(".modal-title").html("提示信息");
  			dialog.find(".modal-dialog").css({width:"500px"});
  			dialog.find(".modal-body").html('');
  			dialog.find(".modal-body").css({"min-height":"80px"});
  			dialog.modal({
  				keyboard: false
  			}).on({
  				'hidden.bs.modal' : function(){
  					$(this).remove();
  				},
  				'shown.bs.modal' : function(){
  					var tmpStr = "<div><strong style='line-height:30px;'>以下病区未设置其隶属的科室，请联系管理员设置</strong></div>";
  					tmpStr += "<div id='newAddWard'></div>";
  					dialog.find(".modal-body").append(tmpStr);
  		        	dialog.find(".modal-body #newAddWard").html(result.join(','));
  				}
  			});
 			});
	});
}